#ifdef ENABLE_NETWORK
#include "../menu.h"
#include "user.h"
#include "Network_SetupEvent.h"
#include "../resource_network/network_icon_date.h"
#include "logo_dat.h"
#include "../aw_network.h"
#include "../aw_config.h"
#include "net/iwconfig/iwlib.h"
#include "WinwarnMessageBoxEvent.h"
static INT8U PicInfo_Highlight=0;
static INT8U PicInfo_Highlight2=0;
INT8U PicInfo_Highlight1=0;
static INT8U Securyty_Hight=0;
INT8U Ipaddress_Hight=0;
static INT8U Connect_Hight=0;
extern INT8U key_menu_flag;
extern struct aml_iw_config aml_wireless_config;
extern INT8U ssid_num;
extern INT8U IsDongleDetected_flag;
extern struct iwscan_state *Scan_Result;
extern INT8U net_sync_flag;
extern INT8U Gallery_location;
char output_point[IW_ESSID_MAX_SIZE + 1];
extern INT8U frame_init_net_flag;
extern INT8U keyboard_parent_flag;
static INT8U process_percent=0;
 INT8U menu_index_process=0;
static INT8U process_quit_timer=0;
static INT8U refresh_flag=0;
extern INT8U Yahoo_already_connected;
extern INT8U Google_already_connected;
extern INT8U FrameChannel_already_connected;
extern u8_t yahoo_auto_enable;
extern u8_t google_auto_enable;
extern yahoo_login_info_t yahoo_config;
extern google_login_info_t google_config;
extern framechannel_login_info_t framechannel_config;
static INT8U UP_DOWN_HIGHT=3;
static INT8U YAHOO_UP_DOWN_HIGHT=3;
static INT8U GOOGLE_UP_DOWN_HIGHT=3;
static INT8U FRAME_UP_DOWN_HIGHT=2;
u8_t net_cont_status = NONE;
void Flash_Caption_str(INT8U menu_id)
{
	PHWND hwnd= AWFindWinCtrlByName("Caption_Set") ;
	switch(menu_id)
	{
		case ID_MENU_INFO_SCANNING:
			hwnd->draw_info[2].draw_pos_x =600;	
			hwnd->draw_info[2].draw_data = (INT32U)SCAN_RESULT;
			break;
		case ID_MENU_MANUAL_MODE:
			hwnd->draw_info[2].draw_pos_x =600;	
			hwnd->draw_info[2].draw_data = (INT32U)MANUAL_SETTING;
			break;	
		case ID_INTERNET_YAHOO_SETTING:
			hwnd->draw_info[2].draw_pos_x =600;	
			hwnd->draw_info[2].draw_data = (INT32U)INTERNET_YAHOO_SETTING;
			break;
			
        case ID_INTERNET_GOOGLE_SETTING:	
			hwnd->draw_info[2].draw_pos_x =600;	
		  	hwnd->draw_info[2].draw_data = (INT32U)INTERNET_GOOGLE_SETTING;
			break;	

        case ID_INTERNET_FRAME_CHNL_SETTING:
		 	hwnd->draw_info[2].draw_pos_x =516;
		 	hwnd->draw_info[2].draw_data = (INT32U)INTERNET_RSS_SETTING;
			break;

        default:
            break;
    }
	AWPostMessage(hwnd, WM_PAINT_DRAW_INFO, 1) ;
	AWPostMessage(hwnd, WM_PAINT_DRAW_INFO, 2) ;
	AWPostMessage(hwnd, WM_PAINT_FINISH, 0) ;
}

void repaint_message(void)
{
	INT32S lpParam;
	PHWND hwnd=AWFindWinCtrlByName("WarningBox") ;
	
	
	AWSendMessage(hwnd, WM_PAINT_DRAW_INFO, 0) ;
	AWSendMessage(hwnd, WM_PAINT_DRAW_INFO, 1) ;
	AWSendMessage(hwnd, WM_PAINT_DRAW_INFO, 2) ;
	AWSendMessage(hwnd, WM_PAINT_DRAW_INFO, 3) ;
	AWSendMessage(hwnd, WM_PAINT_DRAW_INFO, 4) ;
	AWSendMessage(hwnd, WM_PAINT_DRAW_INFO, 5) ;
	AWSendMessage(hwnd, WM_PAINT_FINISH, 0) ;
	AWSendMessage(hwnd, WM_PAINT, 0) ;
	AWSendMessage(hwnd, WM_PAINT_FINISH, 0) ;
	}

static void Set_ManuScan_Date(PHWND hwnd, INT8U Highlight,INT8U Left_right)
{
	if(Highlight==0)
	{
		hwnd->draw_info[2].draw_data = (INT32U)APNAME_STR[0];
		hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 0) ;       
		hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 1) ;
		hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 2) ;
		hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0) ;		
	}
	else if(Highlight==1)
		{
			if(Left_right)
			{
				if(Securyty_Hight<2)
				{
					Securyty_Hight++;
				}
				else if(Securyty_Hight==2)
					{
						Securyty_Hight=0;
					}	
			} 		
		        else if(!Left_right)
			{	
				if(Securyty_Hight>0)
				{	  
					Securyty_Hight--;	
				}
				else if(Securyty_Hight==0) 
					Securyty_Hight=2;
			}    
				
			switch(Securyty_Hight)
			{
				case 0:			
					hwnd->draw_info[5].draw_data = (INT32U)SECURYTY_STR_OPEN;
					break;
			    
				case 1:			
					hwnd->draw_info[5].draw_data = (INT32U)SECURYTY_STR_WEP;
					break;
			    
				case 2:			
					hwnd->draw_info[5].draw_data = (INT32U)SECURYTY_STR_WPA;
					break;    
				default:
					return;			 	   
			}
			hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 3) ;       
			hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 4) ;
			hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 5) ;
			hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0) ;			
			}
	else if(Highlight==2)
		{
						 	
			Ipaddress_Hight=!Ipaddress_Hight;
	        	
			switch(Ipaddress_Hight)
			{
				case 0:			
					hwnd->draw_info[8].draw_data = (INT32U)IPADDRESS_STR_AUTO;
					break;
			    
				case 1:			
					hwnd->draw_info[8].draw_data = (INT32U)IPADDRESS_STR_STATIC;
					break;  
				default:
					return;   
			}
			hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 6) ;       
			hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 7) ;
			hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 8) ;
			hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0) ;		
		}				
	}

static void Set_ManuScan_Date1(PHWND hwnd, INT8U Highlight,INT8U Left_right)
{
	if(Highlight==2)
	{					 	
		Connect_Hight=!Connect_Hight;	        	
		switch(Connect_Hight)
		{
			case 0:			
				hwnd->draw_info[8].draw_data = (INT32U)INTER_AUTO_STR;
				break;			    
			case 1:			
				hwnd->draw_info[8].draw_data = (INT32U)INTER_MANUAL_STR;
				break;  
			default:
				return;   
		}
		hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 6) ;       
		hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 7) ;
		hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 8) ;
		hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0) ;		
	}						
}


static void SetPicInfoPanelData(PHWND hwnd, INT8U PreHighlight, INT8U CurHighlight)
{
    //PIXELVAL old_color ;
	hwnd->draw_info[PreHighlight*3].draw_data = (INT32U)ICON_NET_SETUP_BAR;
	hwnd->draw_info[CurHighlight*3].draw_data = (INT32U)ICON_NET_SETUP_SELECT_BAR;
    
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, PreHighlight*3);
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, PreHighlight*3+1);
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, PreHighlight*3+2);
    //old_color = AWSetForeground(4);
    
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, CurHighlight*3);
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, CurHighlight*3+1);
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, CurHighlight*3+2);
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0);
    
    //AWSetForeground(old_color) ;

}

static void SetPicInfoPanelData1(PHWND hwnd, INT8U PreHighlight, INT8U CurHighlight)
{
    //PIXELVAL old_color ;
	hwnd->draw_info[PreHighlight*2].draw_data = (INT32U)ICON_NET_SETUP_BAR;
	hwnd->draw_info[CurHighlight*2].draw_data = (INT32U)ICON_NET_SETUP_SELECT_BAR;
    
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, PreHighlight*2);
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, PreHighlight*2+1);

    //old_color = AWSetForeground(4);
    
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, CurHighlight*2);
	hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, CurHighlight*2+1);

	hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0);
    
    //AWSetForeground(old_color) ;

}

INT32S Network_SetupOnShow(PHWND hwnd, INT32S lpParam)
{
	osdsettpval(2,0xf);
	return 0 ;
}
INT32S Network_SetupOnKeyPress(PHWND hwnd, INT32S lpParam)
{

	return 0 ;
}
INT32S ManuScanOnShow(PHWND hwnd, INT32S lpParam)
{
   // hwnd->draw_info[2].draw_data = (INT32U)APNAME_STR[PicInfo_Highlight1];
   
	if(!Securyty_Hight)
	{
		hwnd->draw_info[5].draw_data = (INT32U)SECURYTY_STR_OPEN;
	}
	else if(Securyty_Hight==1)
	{
		hwnd->draw_info[5].draw_data = (INT32U)SECURYTY_STR_WEP;
	}	
	else if(Securyty_Hight==2)
	{
		hwnd->draw_info[5].draw_data = (INT32U)SECURYTY_STR_WPA;
	}			
    
	return 0 ;
}

INT32S ManuScanOnKeyPress(PHWND hwnd, INT32S lpParam)
{
	
	INT8U Highlight_temp=0;
	Highlight_temp = PicInfo_Highlight;
	INT32U *key_value = (INT32U *)lpParam ;
	switch(*key_value)
	{
 		case UOP_RESUME:
			GUIHideWindow("Network_Setup");
			GUIShowWindow("WinSetup_net_menu");	 	
			break;	
		case UOP_DOWN:
		
			if(PicInfo_Highlight < 3)
			{
				PicInfo_Highlight ++;
				SetPicInfoPanelData(hwnd, Highlight_temp, PicInfo_Highlight);
			}   
			break;
		
		case UOP_UP:
			if(PicInfo_Highlight >0)
			{
				PicInfo_Highlight --;
				SetPicInfoPanelData(hwnd, Highlight_temp, PicInfo_Highlight);
			}
		
			break;
		case UOP_LEFT:
			Set_ManuScan_Date(hwnd,PicInfo_Highlight,0);
	 	
			break;
		case UOP_RIGHT:
			Set_ManuScan_Date(hwnd,PicInfo_Highlight,1);
		
			break;
		
		case UOP_ENTER:
			if(!PicInfo_Highlight)
			{
				key_menu_flag=ID_MENU_MANUAL_SSID;			
				GUIHideWindow("Network_Setup");
				GUIShowWindow("WinKeyBoard");			  	
			}
		
			if(PicInfo_Highlight==1)
			{
				if(!Securyty_Hight){
					aml_wireless_config.security = IW_SECURITY_NONE;
					return;
				}
				else if(Securyty_Hight==1)
				{		
					key_menu_flag=ID_MENU_MANUAL_WEP;	
					GUIHideWindow("Network_Setup");
					GUIShowWindow("WinKeyBoard");	
				}
				else if(Securyty_Hight==2)
				{
					key_menu_flag=ID_MENU_MANUAL_WPA;	
					GUIHideWindow("Network_Setup");
					GUIShowWindow("WinKeyBoard");	
				}			 
			}
			else if(PicInfo_Highlight==2)
			{
				if(!Ipaddress_Hight)
				{
					return;
				}
				else if(Ipaddress_Hight)	
				{
					key_menu_flag=ID_MENU_MANUAL_IP_ADDRESS;
					GUIHideWindow("Network_Setup");
					GUIShowWindow("WinNumberKeyBoard");	
				}			   	
			
			}		 	
			else if(PicInfo_Highlight==3)
			{
				if(strlen(aml_wireless_config.essid)){
						
					menu_index_process=ID_MENU_INFO_CONNECTING;
					GUIShowWindow("WinWarnMessageBox");				
					Start_Connect(&aml_wireless_config);
				}		    		
			}              
			break;
		default:
			break;		
		}
	
	return 0 ;
}

INT32S Caption_SetOnShow(PHWND hwnd, INT32S lpParam)
{
	Flash_Caption_str(menu_index_process);     
	return 0 ;
}
INT32S Scan_resultOnShow(PHWND hwnd, INT32S lpParam)
{      
	memset(APNAME_STR[0],0,sizeof(APNAME_STR));
	for(int i=0;i<ssid_num;i++)
	{
		memset(APNAME_STR[i],0,sizeof(APNAME_STR[i]));
		strcpy(APNAME_STR[i],net_id_intension_str[i]);
	}
				
	return 0 ;
}

INT32S Scan_resultOnPaint(PHWND hwnd, INT32S lpParam)
{
   // PIXELVAL old_color;
   // old_color = AWSetForeground(AW_BLACK_COLOR) ;
  //hwnd->pClass->ClassProc(hwnd, WM_PAINT, lpParam) ;  
   // AWAsciiPrintf(110,354,net_message[0]);
   // AWSetForeground(old_color) ;
    	
    //return 1 ;
	return 0;
}
INT32S Scan_resultOnKeyPress(PHWND hwnd, INT32S lpParam)
{      
	INT8U Highlight_temp1=0;
	Highlight_temp1 = PicInfo_Highlight1;
	INT32U *key_value = (INT32U *)lpParam ;
	int ap_mode;
	switch(*key_value)
	{
		case UOP_RESUME:
			GUIHideWindow("Network_Setup");
			GUIShowWindow("WinSetup_net_menu");
			break;
		case UOP_DOWN:
		
			if(PicInfo_Highlight1< ssid_num-1)
			{
				PicInfo_Highlight1 ++;
				SetPicInfoPanelData1(hwnd, Highlight_temp1, PicInfo_Highlight1);
			}   
			break;
		
		case UOP_UP:
			if(PicInfo_Highlight1>0)
			{
				PicInfo_Highlight1 --;
				SetPicInfoPanelData1(hwnd, Highlight_temp1, PicInfo_Highlight1);
			}		
			break;
	      
		case UOP_ENTER:
			Dynamic_IP(); //scan->connect,get IP address through DHCP
#if 0
            if(TotalSelect_flag==TotalSelectNumber-1)
            {
				PresetMenuNotOnShown(ID_MENU_NETWORK_NOT_ONSHOW);
                GUIShowWindow("Windialog");	
			}
#endif

            /* Wireless scan -> select AP case */
			strcpy(output_point,net_id_str[PicInfo_Highlight1]);
			memset(APNAME_STR[0],0,sizeof(APNAME_STR[0]));
			strcpy(APNAME_STR[0],output_point);

			ap_mode=Get_AP_Mode_Setting(Scan_Result,output_point);
			int ret = Get_Security_Setting(Scan_Result, output_point);
			if(ret)
			{
				if(ret == IW_SECURITY_WEP){
					key_menu_flag=ID_MENU_SECURITY_WEP;
				}else if(ret == IW_SECURITY_WPA){
					key_menu_flag=ID_MENU_SECURITY_WPA;
				}else if(ret == IW_SECURITY_WPA2){
					key_menu_flag=ID_MENU_SECURITY_WPA;
	     				}	                
	     				//GUIHideWindow("WinKeyBoard");	
				keyboard_parent_flag=10;
				GUIShowWindow("WinKeyBoard");	 
            				//iw_free_scan_list(Scan_Result);
            				//Scan_Result = NULL;			/*  needn't free at once */
			}
             			//if(Get_Security_Setting(Scan_Result, output_point))
              		//{
                 		//PresetMenuEnable(ID_MENU_SECURITY_WEP_WPA);
                 		//RestartPaint();
                 		//iw_free_scan_list(Scan_Result);
                 		//Scan_Result = NULL;
                 		//}
			else
			{
	                    	/* Wireless scan -> select AP -> no security case */
	                    	/* Save SSID name. */
				strncpy(aml_wireless_config.essid, (char *)output_point, IW_ESSID_MAX_SIZE);
	                    /* No security */
				aml_wireless_config.key[0] = '\0';
				aml_wireless_config.key_len = 0;
				aml_wireless_config.security = IW_SECURITY_NONE;
	                    		
				menu_index_process= ID_MENU_INFO_CONNECTING;
				GUIHideWindow("Network_Setup");
				GUIShowWindow("WinWarnMessageBox");
	                 		
				Start_Connect(&aml_wireless_config);
				//GUIShowWindow("WinInfo");
	                 	}		
			break;			
		
	}
	return 0 ;

}
#if 0
void process_quit_post(void)
{
	refresh_flag = 0;

	//SetPrintInfoFlag(0);

	switch(menu_index_process)
	{
		case ID_MENU_INFO_COPYING:
		case ID_MENU_INFO_MARKED_COPYING:
		case ID_MENU_INFO_PRINTING:
		case ID_MENU_INFO_MARKED_PRINTING:
			if(AWGetTopWindow(gpFocusWin) == AWFindWinCtrlByName("WinInfo")){
				SetPrintFlag(0);			
				RefreshFileStatus(0);
				if(CheckMediaPlaybackVideoApp())
					ChangeBackGround();
				else
					ReloadLogoType(0);
				ReturnLastWin();
			}
        		break;
	       case ID_MENU_INFO_DELING:
		case ID_MENU_INFO_MARKED_DELING:
			if(AWGetTopWindow(gpFocusWin) == AWFindWinCtrlByName("WinInfo")){
				RefreshFileStatus(1);
				ReturnLastWin();
			}
        		break;
	       case ID_MENU_INFO_FOLDER_DELING:
	       case ID_MENU_INFO_FOLDER_COPYING:
	       case ID_MENU_INFO_FOLDER_PRINTING:
	    if(AWGetTopWindow(gpFocusWin) == AWFindWinCtrlByName("WinInfo")){
		   	if(CheckMediaPlaybackVideoApp())
				ChangeBackGround();
			else
				ReloadLogoType(0);
				ReturnLastWin_Folder();
			}
	          	break; 
		
#ifdef PRINTER_DEBUG
		case ID_MENU_INFO_PM_CONNECT:
			if(AWGetTopWindow(gpFocusWin) == AWFindWinCtrlByName("WinInfo")){
				if(CheckMediaPlaybackVideoApp())
					ChangeBackGround();
				else
					ReloadLogoType(0);
				if(AWGetTopWindow(Window_ID_FLAG) == AWFindWinCtrlByName("_AWWindowsRoot_"))
					GUIShowWindow("WinHome");
				else
					AWShowWindow(Window_ID_FLAG,1);
			}
			break;		
		case ID_MENU_INFO_PM_DISCONNECT:
			if(AWGetTopWindow(gpFocusWin) == AWFindWinCtrlByName("WinInfo")){
				if(CheckMediaPlaybackVideoApp())
					ChangeBackGround();
				else
					ReloadLogoType(0);
					
			 if(AWGetTopWindow(Window_ID_FLAG) == AWFindWinCtrlByName("_AWWindowsRoot_"))
					GUIShowWindow("WinHome");
			 else if(AWGetTopWindow(Window_ID_FLAG) == AWFindWinCtrlByName("WinInfo"))
					GUIShowWindow("WinHome");
				else
					AWShowWindow(Window_ID_FLAG,1);
			}
			break;		
			
		case ID_MENU_INFO_PM_WARNING:
		case ID_MENU_INFO_PM_ERROR:
			if(AWGetTopWindow(gpFocusWin) == AWFindWinCtrlByName("WinInfo")){
				if(CheckMediaPlaybackVideoApp())
					ChangeBackGround();
				else
					ReloadLogoType(0);
				if(GetPrintFlag()){
					SetPrintFlag(0);
			 		if((OperationFlag == FILEOP_MARKED)||(OperationFlag == FILEOP_UNMARKED)){
			 			RefreshFileStatus(0);
						ReturnLastWin();
			 		}
			 		else if(OperationFlag == FILEOP_FOLDER){
			 			ReturnLastWin_Folder();
			 		}else{
						GUIShowWindow("WinHome");
					}
				}else{
					if(AWGetTopWindow(Window_ID_FLAG) == AWFindWinCtrlByName("_AWWindowsRoot_")){
						GUIShowWindow("WinHome");
					}else if(AWGetTopWindow(Window_ID_FLAG) == AWFindWinCtrlByName("WinInfo")){
						if((OperationFlag == FILEOP_MARKED)||(OperationFlag == FILEOP_UNMARKED)){
			 				RefreshFileStatus(0);
							ReturnLastWin();
			 			}
			 			else if(OperationFlag == FILEOP_FOLDER){
			 				ReturnLastWin_Folder();
			 			}else{
							GUIShowWindow("WinHome");
						}
					}else{ 
						AWShowWindow(Window_ID_FLAG,1);
					}
				}
			}
			break;
#endif		

		case ID_MENU_INFO_SCANNING:
		  break;
		case ID_MENU_INFO_CONNECTING:
		   break;
		case ID_MENU_PLAY_CONNECTED:
			CloseTimeQuit();
			// PresetMenuConnect(1);
			// GUIShowWindow("Windialog");
			PresetMenuProcess_Info(ID_MENU_SCANNING_DEVICE);
			RestartPaintInfo();
		   	break;
		 case ID_MENU_SCANNING_DEVICE:
		 	break;
		 case ID_MENU_DEVICE_COMPLETE:
		 	break;
		 case ID_MENU_HELPME:
		 	break;
		 case ID_MENU_DO_NOT_KNOW:
		 	break;

     		case ID_MENU_ABOUT:
     			break;
		default:
			GUIShowWindow("WinHome");
        		break;
        }
#ifdef ENABLE_USBGADGET
// 2/9 fix bug: insert problem
	//if(menu_index_process != ID_MENU_INFO_UPGRADING)
	//	SetConnectPC(1);
	if((menu_index_process == ID_MENU_SCANNING_DEVICE)
		||(menu_index_process == ID_MENU_INFO_MARKED_DELING)
		||(menu_index_process == ID_MENU_INFO_MARKED_COPYING)
		||(menu_index_process == ID_MENU_INFO_DELING)
		||(menu_index_process == ID_MENU_INFO_COPYING)
		||(menu_index_process == ID_MENU_INFO_FOLDER_DELING)
		||(menu_index_process == ID_MENU_INFO_FOLDER_COPYING))
		SetConnectPC(1);
#endif
}

#endif

static void process_quit_timer_func(void *arg)
{
	
	if (process_quit_timer)
	{
		AVTimerDelete(process_quit_timer);
		process_quit_timer= 0;
	}
    	//process_quit_post();
	
}


void ProcessScroll(INT16U Process,INT8U use_dcache)
{

	unsigned times = 3000;
	INT16U value=Process/10;  
	if(Process == 0xff)
	{
		value = 10;
		times = 60000;
	}
	if(Process == 0xfe)
		{
		if (process_quit_timer) {
        		AVTimerDelete(process_quit_timer);
        		process_quit_timer= 0;
    		}	 
		return;
	}	
	
	process_percent=Process;
	if(!refresh_flag)
		return;
	if(process_percent>100)
	{
		if (!process_quit_timer) 
			process_quit_timer = AVTimerCreateFlag(times, process_quit_timer_func , NULL, AVTIMER_FLAG_PERIODIC); 
        	else
              	AVTimerRestart(process_quit_timer);
	}
	
#if 0
	int i=0,paint_flag=0;
	PHWND hwnd=AWFindWinCtrlByName("Info_ProcessBar");
	if((value>10)||(!hwnd))
		return;
	if(value==0){
		ClearScroll(use_dcache);
		return;
	}
	for(i=1;i<=value;i++){
		if(i==1){
			if(hwnd->draw_info[11-i].draw_data != (INT32U)ICON_PROCESS_BLOCK_BOTTOM){
				hwnd->draw_info[11-i].draw_data = (INT32U)ICON_PROCESS_BLOCK_BOTTOM;
				AWPostMessage(hwnd, WM_PAINT_DRAW_INFO, 11-i);
				paint_flag=1;
			}
		}else if(i==10){
			if(hwnd->draw_info[11-i].draw_data != (INT32U)ICON_PROCESS_BLOCK_TOP){
				 hwnd->draw_info[11-i].draw_data = (INT32U)ICON_PROCESS_BLOCK_TOP;
				 AWPostMessage(hwnd, WM_PAINT_DRAW_INFO, 11-i);
				 paint_flag=1;
			}
		}else{
			if(hwnd->draw_info[11-i].draw_data != (INT32U)ICON_PROCESS_BLOCK_MIDDLE){
				 hwnd->draw_info[11-i].draw_data = (INT32U)ICON_PROCESS_BLOCK_MIDDLE;
				 AWPostMessage(hwnd, WM_PAINT_DRAW_INFO, 11-i);
				 paint_flag=1;
			}
		}
	}
	if((paint_flag)&&(use_dcache))
		AWPostMessage(hwnd, WM_PAINT_FINISH,0);
#endif
}

INT32S Internet_SettingOnShow(PHWND hwnd, INT32S lpParam)
{
    static char AccountID[20];
	INT32S word_width = 300,font_height, word_len, str_len ;
	        
	if(PicInfo_Highlight2>=3)
	{
		PicInfo_Highlight2=2; 
		hwnd->draw_info[3*3].draw_data = (INT32U)ICON_NET_SETUP_BAR;
		hwnd->draw_info[2*3].draw_data = (INT32U)ICON_NET_SETUP_SELECT_BAR;
   	}

	if (menu_index_process == ID_INTERNET_YAHOO_SETTING)
	{
		GetYahooConfig(&yahoo_config);
		strcpy(AccountID,yahoo_config.username);
		hwnd->draw_info[2].draw_data = (INT32U)AccountID;
		str_len = AWGetTextSize(AccountID, 0,&word_width,&font_height,&word_len, AWTF_ASCII) ;
		if(strlen(AccountID)>str_len)
			{
				AccountID[str_len-2]='~';
		        AccountID[str_len-1]=0;
			}
		if (yahoo_config.passphrase[0])
			hwnd->draw_info[5].draw_data = (INT32U)star_password;
        else
			hwnd->draw_info[5].draw_data = (INT32U)internet_setting[1];

		GetYahooAutoEnable(&yahoo_auto_enable);
		if (yahoo_auto_enable) {
            hwnd->draw_info[8].draw_data  = (INT32U)INTER_AUTO_STR;
			hwnd->draw_info[10].draw_data = (INT32U)0;
            YAHOO_UP_DOWN_HIGHT = 2;
        }
        else
		{
            hwnd->draw_info[8].draw_data = (INT32U)INTER_MANUAL_STR;

			if (Yahoo_already_connected)
				hwnd->draw_info[10].draw_data = (INT32U)DISCONNECT_STR;
			else
				hwnd->draw_info[10].draw_data = (INT32U)CONNECT_STR;

            YAHOO_UP_DOWN_HIGHT = 3;
		}
	}
	else if (menu_index_process == ID_INTERNET_GOOGLE_SETTING)
	{
       	strcpy(AccountID,google_config.username);
		hwnd->draw_info[2].draw_data = (INT32U)AccountID;
		str_len = AWGetTextSize(AccountID, 0,&word_width,&font_height,&word_len, AWTF_ASCII) ;
		if(strlen(AccountID)>str_len)
			{
				AccountID[str_len-2]='~';
		        AccountID[str_len-1]=0;
			}

        if (google_config.passphrase[0])
			hwnd->draw_info[5].draw_data = (INT32U)star_password;
        else
			hwnd->draw_info[5].draw_data = (INT32U)internet_setting[3];

		GetGoogleAutoEnable(&google_auto_enable);
		if (google_auto_enable) {
            hwnd->draw_info[8].draw_data  = (INT32U)INTER_AUTO_STR;
			hwnd->draw_info[10].draw_data = (INT32U)0;
            GOOGLE_UP_DOWN_HIGHT = 2;
        }
        else {
            hwnd->draw_info[8].draw_data = (INT32U)INTER_MANUAL_STR;

			if (Google_already_connected)
				hwnd->draw_info[10].draw_data = (INT32U)DISCONNECT_STR;
            else
				hwnd->draw_info[10].draw_data = (INT32U)CONNECT_STR;

            GOOGLE_UP_DOWN_HIGHT = 3;
        }
	}
	else if (menu_index_process == ID_INTERNET_FRAME_CHNL_SETTING)
	{
        strcpy(AccountID,framechannel_config.username);
		hwnd->draw_info[2].draw_data = (INT32U)AccountID;
		str_len = AWGetTextSize(AccountID, 0,&word_width,&font_height,&word_len, AWTF_ASCII) ;
		if(strlen(AccountID)>str_len)
			{
				AccountID[str_len-2]='~';
		        AccountID[str_len-1]=0;
			}
 

        if (framechannel_config.passphrase[0])
			hwnd->draw_info[5].draw_data = (INT32U)star_password;		
        else
			hwnd->draw_info[5].draw_data = (INT32U)internet_setting[5];

        hwnd->draw_info[8].draw_data = (INT32U)INTER_AUTO_STR;

		if (FRAME_UP_DOWN_HIGHT == 3)
		{
			if (FrameChannel_already_connected)
				hwnd->draw_info[10].draw_data = (INT32U)DISCONNECT_STR;	
            else
				hwnd->draw_info[10].draw_data = (INT32U)CONNECT_STR;		
		}
		else if (FRAME_UP_DOWN_HIGHT == 2)	 
			hwnd->draw_info[10].draw_data = (INT32U)0;
	}
	
	return 0 ;
}

INT32S Internet_SettingOnKeyPress(PHWND hwnd, INT32S lpParam)
{
	INT8U Highlight_temp=0;
	Highlight_temp = PicInfo_Highlight2;
	INT8U enable=0;
	INT32U *key_value = (INT32U *)lpParam ;
	
	switch(*key_value)
	{
 
    case UOP_RESUME:
	 	GUIHideWindow("Network_Setup");
	 	GUIShowWindow("WinSetup_net_menu");
	 	break;	

	case UOP_DOWN:
        if(menu_index_process==ID_INTERNET_YAHOO_SETTING)
		 	UP_DOWN_HIGHT=YAHOO_UP_DOWN_HIGHT;
        else if(menu_index_process==ID_INTERNET_GOOGLE_SETTING)
		 	UP_DOWN_HIGHT=GOOGLE_UP_DOWN_HIGHT; 	
        else if(menu_index_process==ID_INTERNET_FRAME_CHNL_SETTING)
		 	UP_DOWN_HIGHT=FRAME_UP_DOWN_HIGHT;

        if(PicInfo_Highlight2 < UP_DOWN_HIGHT)
        {
            PicInfo_Highlight2 ++;
            SetPicInfoPanelData(hwnd, Highlight_temp, PicInfo_Highlight2);
        }
      break;
		
	case UOP_UP:
		if(PicInfo_Highlight2 >0)
		{
			PicInfo_Highlight2 --;
			SetPicInfoPanelData(hwnd, Highlight_temp, PicInfo_Highlight2);
		}
		
		break;
    case UOP_LEFT:
	 	Set_ManuScan_Date1(hwnd,PicInfo_Highlight2,0);
	 	
	 	break;
	case UOP_RIGHT:
		Set_ManuScan_Date1(hwnd,PicInfo_Highlight2,1);
		
		break;
		
	case UOP_ENTER:
		
		if(!PicInfo_Highlight2)
		{
			key_menu_flag=ID_MENU_MANUAL_URL;			
			GUIHideWindow("Network_Setup");
			GUIShowWindow("WinKeyBoard");			  	
		}
        else if(PicInfo_Highlight2==1)
		{
			key_menu_flag=ID_MENU_MANUAL_PASSWORD;
			GUIHideWindow("Network_Setup");
			GUIShowWindow("WinKeyBoard");
			 
		}				
        else if (PicInfo_Highlight2 == 2)
		{
			if (!Connect_Hight)                //auto mode
			{
				enable = 1;	
				if (menu_index_process == ID_INTERNET_YAHOO_SETTING)
				{
					/* Yahoo */
			   		SetYahooAutoEnable(1);

					LogOnOff(LOGON_TYPE_YAHOO | LOGON_FLAG | LOGON_SHOWCURSOR, yahoo_config.username, yahoo_config.passphrase);
					YAHOO_UP_DOWN_HIGHT = 2;
				}
				else if (menu_index_process == ID_INTERNET_GOOGLE_SETTING)
				{
					/* Google */
			   		SetGoogleAutoEnable(1);

					LogOnOff(LOGON_TYPE_GOOGLE | LOGON_FLAG | LOGON_SHOWCURSOR, google_config.username, google_config.passphrase);
			   		GOOGLE_UP_DOWN_HIGHT = 2;
				}	
				else if (menu_index_process == ID_INTERNET_FRAME_CHNL_SETTING)
				{
                    /* Framechannel */
					LogOnOff(LOGON_FLAG | LOGON_SHOWCURSOR, framechannel_config.username, framechannel_config.passphrase);
			   		FRAME_UP_DOWN_HIGHT = 2;
				}

                //hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 9);
				hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0);
			}
			else if(Connect_Hight)	   //manual mode
			{       
				enable = 0;	
				if(menu_index_process==ID_INTERNET_YAHOO_SETTING)
				{
                    /* Yahoo */
			   		SetYahooAutoEnable(0);
					//LogOnOff(LOGON_TYPE_YAHOO | LOGOFF_FLAG,NULL,NULL);
					YAHOO_UP_DOWN_HIGHT = 3;
					if(Yahoo_already_connected)
						hwnd->draw_info[10].draw_data = (INT32U)DISCONNECT_STR;
					else
						hwnd->draw_info[10].draw_data = (INT32U)CONNECT_STR;
				}
				else if(menu_index_process==ID_INTERNET_GOOGLE_SETTING)
				{
                    /* Google */
			   		SetGoogleAutoEnable(0);
					//LogOnOff(LOGON_TYPE_GOOGLE | LOGOFF_FLAG, NULL, NULL);
					GOOGLE_UP_DOWN_HIGHT = 3;
					if(Google_already_connected)
						hwnd->draw_info[10].draw_data = (INT32U)DISCONNECT_STR;
					else
						hwnd->draw_info[10].draw_data = (INT32U)CONNECT_STR;
				}	
				else if(menu_index_process==ID_INTERNET_FRAME_CHNL_SETTING)
				{
                    /* Framechannel */
					//LogOnOff(LOGOFF_FLAG, NULL, NULL);
			   		FRAME_UP_DOWN_HIGHT=3;
					if(FrameChannel_already_connected)
						hwnd->draw_info[10].draw_data = (INT32U)DISCONNECT_STR;
					else
						hwnd->draw_info[10].draw_data = (INT32U)CONNECT_STR;
				}

				//hwnd->draw_info[10].draw_data = (INT32U)CONNECT_STR;
				hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 9);
				hwnd->pClass->ClassProc(hwnd, WM_PAINT_DRAW_INFO, 10);
				hwnd->pClass->ClassProc(hwnd, WM_PAINT_FINISH, 0);
            }
		}
		else if (PicInfo_Highlight2 == 3)
		{
			if (menu_index_process == ID_INTERNET_YAHOO_SETTING)
			{ 	
				if (!Yahoo_already_connected)
				{		
					if (yahoo_config.username[0] == 0)
					{		    	 			
						menu_index_process = ID_MENU_NONE_ID_PASSWORD;	
					}
					else
					{				
						LogOnOff(LOGON_TYPE_YAHOO | LOGON_FLAG | LOGON_SHOWCURSOR, yahoo_config.username, yahoo_config.passphrase);
						menu_index_process = ID_MENU_CONNECT_NETWORK;
					}

					GUIShowWindow("WinWarnMessageBox");
				}
				else
				{
					LogOnOff(LOGON_TYPE_YAHOO | LOGOFF_FLAG, NULL, NULL) ;	//stop yahoo service 
					menu_index_process = ID_MENU_DISCONNECT__SUCCESS1;
					GUIShowWindow("WinWarnMessageBox");
//					change_warning_message(menu_index_process);
				}
			}
			else if (menu_index_process == ID_INTERNET_GOOGLE_SETTING)
			{
				if (!Google_already_connected)
				{
					if(google_config.username[0] == 0)
					{		    	 			
						menu_index_process = ID_MENU_NONE_ID_PASSWORD;	
					}	
					else
					{			
						LogOnOff( LOGON_TYPE_GOOGLE|LOGON_FLAG|LOGON_SHOWCURSOR,google_config.username,google_config.passphrase);
						menu_index_process = ID_MENU_CONNECT_NETWORK;
					}

					GUIShowWindow("WinWarnMessageBox");
				}
				else
				{
					LogOnOff( LOGON_TYPE_GOOGLE|LOGOFF_FLAG,NULL,NULL ) ;	 //stop google service
					menu_index_process = ID_MENU_DISCONNECT__SUCCESS2;
					GUIShowWindow("WinWarnMessageBox");
//					change_warning_message(menu_index_process);
				}
			}
			else if (menu_index_process == ID_INTERNET_FRAME_CHNL_SETTING)
			{
                /* FrameChannel */
                    if (!FrameChannel_already_connected) 
                    {
                    LogOnOff(LOGON_FLAG | LOGON_SHOWCURSOR, framechannel_config.username, framechannel_config.passphrase);
                        menu_index_process = ID_MENU_CONNECT_NETWORK;

                        GUIShowWindow("WinWarnMessageBox");
                    }
                    else 
                    {
                        LogOnOff(LOGOFF_FLAG, NULL, NULL);
                        menu_index_process = ID_MENU_DISCONNECT_SUCCESS_FRAMECHANNEL;
                        GUIShowWindow("WinWarnMessageBox");
 //                       change_warning_message(menu_index_process);
                    }
                }
			}
       		    		          
		break;
	default:
		break;
						
		
	}
	
   
    return 0 ;
}
INT32S Internet_SettingOnPaint(PHWND hwnd, INT32S lpParam)
{
	return 0 ;
}

#endif
